/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.willy.example;

import com.willy.ratingbar.NumberUntil;
import com.willy.ratingbar.RotationRatingBar;

import ohos.agp.components.BaseItemProvider;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;

/**
 * s1d
 *
 * @since 2021-03-26
 */
public class SampleItemProvider extends BaseItemProvider {
    private RotationRatingBar rotationRatingBar;
    private Context slice;
    private Component component = null;

    /**
     * dad
     *
     * @param slice q
     */
    public SampleItemProvider(Context slice) {
        this.slice = slice;
    }

    @Override
    public int getCount() {
        return NumberUntil.getAnInt19();
    }

    @Override
    public Object getItem(int position) {
        return component;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) {
        Component cpt = LayoutScatter.getInstance(slice).parse(ResourceTable.Layout_item_ratingbar, null, false);
        rotationRatingBar = (RotationRatingBar) cpt.findComponentById(ResourceTable.Id_Rotion);
        rotationRatingBar.setAmtionPost(1);
        if (position == 0) {
            rotationRatingBar.setColor(1);
        } else if (position == 1) {
            rotationRatingBar.setColor(NumberUntil.getAnInt2());
        } else if (position == NumberUntil.getAnInt2()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt3());
        } else if (position == NumberUntil.getAnInt3()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt4());
        } else if (position == NumberUntil.getAnInt4()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt5());
        } else if (position == NumberUntil.getAnInt5()) {
            rotationRatingBar.setColor(0);
        } else if (position == NumberUntil.getAnInt6()) {
            rotationRatingBar.setColor(1);
        } else if (position == NumberUntil.getAnInt7()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt2());
        } else if (position == NumberUntil.getAnInt8()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt3());
        } else if (position == NumberUntil.getAnInt9()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt4());
        } else if (position == NumberUntil.getAnInt10()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt5());
        } else if (position == NumberUntil.getAnInt11()) {
            rotationRatingBar.setColor(0);
        } else if (position == NumberUntil.getAnInt12()) {
            rotationRatingBar.setColor(1);
        } else if (position == NumberUntil.getAnInt13()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt2());
        } else if (position == NumberUntil.getAnInt14()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt3());
        } else if (position == NumberUntil.getAnInt15()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt4());
        } else if (position == NumberUntil.getAnInt16()) {
            rotationRatingBar.setColor(NumberUntil.getAnInt5());
        } else if (position == NumberUntil.getAnInt17()) {
            rotationRatingBar.setColor(0);
        } else if (position == NumberUntil.getAnInt18()) {
            rotationRatingBar.setColor(1);
        }
        return cpt;
    }
}